package word_help;

import java.util.Comparator;
import java.util.Map;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 * User: luotao
 * Date: 11-9-20
 * Time: 15:51:00
 */
public class Period {

    public int id;
    //
    public Map<String, Unit> map = new TreeMap<String, Unit>(new Comparator<String>() {

        public int compare(String o1, String o2) {

            String s1 = o1.replaceAll("[a-z]|[A-Z]", "").trim();
            Integer i1 = Integer.valueOf(s1);

            String s2 = o2.replaceAll("[a-z]|[A-Z]", "").trim();
            Integer i2 = Integer.valueOf(s2);


            return i1 - i2;
        }
    });

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public Map<String, Unit> getMap() {
        return map;
    }

    public void setMap(Map<String, Unit> map) {
        this.map = map;
    }

    public void addUnit(Unit word) {
        map.put(word.getName(), word);
    }

    @Override
    public String toString() {
        return String.valueOf(id);
    }
}
